<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of "myWiWall".
# Copyright (c) 2007-2008 CRP Henri Tudor and contributors.
# All rights reserved.
#
# "myWiWall" is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
# 
# "myWiWall" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with "myWiWall"; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****


/**
 * this code is executed before all other script
 */

# all error
error_reporting(E_ALL);

#magic_quotes_gpc must die.
ini_set('magic_quotes_gpc', 'Off');

# xdebug custom error reporting
if (function_exists("xdebug_enable"))  {
	xdebug_enable();
}

# here are loaded all dependencies that are not object oriented.
# (object oriented dependancies are )
// TODO Imagine a final solution for non oriented object libraries autoloading.
require_once dirname(__FILE__). "/config.php";
require_once dirname(__FILE__).'/clearbricks/common/_main.php';
$__autoload['fileUnzip'] 		= dirname(__FILE__) . '/clearbricks/zip/class.unzip.php';
$__autoload['dbLayer'] 			= dirname(__FILE__) . '/clearbricks/dblayer/dblayer.php';
$__autoload['mysqlConnection'] 		= dirname(__FILE__) . '/clearbricks/dblayer/class.mysql.php';
$__autoload['dbLayerSingleton'] = dirname(__FILE__) . '/db/dblayerSingleton.php';

// include phpopenid library
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__).'/phpopenid/');
require_once "Auth/OpenID/Discover.php";
$__autoload['Auth_OpenID'] = dirname(__FILE__).'/phpopenid/Auth/OpenID.php';
$__autoload['Auth_Yadis_XMLParser'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XML.php';
$__autoload['Auth_Yadis_domxml'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XML.php';
$__autoload['Auth_Yadis_dom'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XML.php';
$__autoload['Auth_Yadis_ParseHTML'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/ParseHTML.php';
$__autoload['Auth_Yadis_DiscoveryResult'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Yadis.php';
$__autoload['Auth_Yadis_Yadis'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Yadis.php';
$__autoload['Auth_Yadis_Service'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XRDS.php';
$__autoload['Auth_Yadis_XRDS'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XRDS.php';
$__autoload['Auth_Yadis_PlainHTTPFetcher'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/PlainHTTPFetcher.php';
$__autoload['Auth_Yadis_PHPSession'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_Yadis_SessionLoader'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_OpenID_ServiceEndpointLoader'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_Yadis_ManagerLoader'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_Yadis_Manager'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_Yadis_Discovery'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/Manager.php';
$__autoload['Auth_Yadis_ProxyResolver'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/XRIRes.php';
$__autoload['Auth_Yadis_ParanoidHTTPFetcher'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/ParanoidHTTPFetcher.php';
$__autoload['Auth_Yadis_HTTPResponse'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/HTTPFetcher.php';
$__autoload['Auth_Yadis_HTTPFetcher'] = dirname(__FILE__).'/phpopenid/Auth/Yadis/HTTPFetcher.php';
$__autoload['Auth_OpenID_TrustRoot'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/TrustRoot.php';
$__autoload['Auth_OpenID_DumbStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/DumbStore.php';
$__autoload['Auth_OpenID_KVForm'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/KVForm.php';
$__autoload['Auth_OpenID_Consumer'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_DiffieHellmanSHA1ConsumerSession'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_DiffieHellmanSHA256ConsumerSession'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_PlainTextConsumerSession'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_GenericConsumer'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_AuthRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_ConsumerResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_SuccessResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_FailureResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_TypeURIMismatch'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_ServerErrorContainer'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_CancelResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_SetupNeededResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Consumer.php';
$__autoload['Auth_OpenID_PostgreSQLStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/PostgreSQLStore.php';
$__autoload['Auth_OpenID_MathLibrary'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/BigMath.php';
$__autoload['Auth_OpenID_BcMathWrapper'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/BigMath.php';
$__autoload['Auth_OpenID_GmpMathWrapper'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/BigMath.php';
$__autoload['Auth_OpenID_MySQLStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/MySQLStore.php';
$__autoload['Auth_OpenID_ServerRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/ServerRequest.php';
$__autoload['Auth_OpenID_ServiceEndpoint'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Discover.php';
$__autoload['Auth_OpenID_OpenIDStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Interface.php';
$__autoload['Auth_OpenID_Extension'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Extension.php';
$__autoload['Auth_OpenID_Association'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Association.php';
$__autoload['Auth_OpenID_SessionNegotiator'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Association.php';
$__autoload['Auth_OpenID_FileStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/FileStore.php';
$__autoload['Auth_OpenID_CryptUtil'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/CryptUtil.php';
$__autoload['Auth_OpenID_SQLiteStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/SQLiteStore.php';
$__autoload['Auth_OpenID_Parse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Parse.php';
$__autoload['Auth_OpenID_Mapping'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Message.php';
$__autoload['Auth_OpenID_NamespaceMap'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Message.php';
$__autoload['Auth_OpenID_Message'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Message.php';
$__autoload['Auth_OpenID_SQLStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/SQLStore.php';
$__autoload['Auth_OpenID_PAPE_Request'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/PAPE.php';
$__autoload['Auth_OpenID_PAPE_Response'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/PAPE.php';
$__autoload['Auth_OpenID_MemcachedStore'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/MemcachedStore.php';
$__autoload['Auth_OpenID_DiffieHellman'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/DiffieHellman.php';
$__autoload['Auth_OpenID_ServerError'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_NoReturnToError'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_MalformedReturnURL'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_MalformedTrustRoot'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_Request'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_CheckAuthRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_PlainTextServerSession'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_DiffieHellmanSHA1ServerSession'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_AssociateRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_CheckIDRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_ServerResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_WebResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_Signatory'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_Encoder'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_SigningEncoder'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_Decoder'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_EncodingError'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_AlreadySigned'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_UntrustedReturnURL'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_Server'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/Server.php';
$__autoload['Auth_OpenID_DatabaseConnection'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/DatabaseConnection.php';
$__autoload['Auth_OpenID_AX'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_Error'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_Message'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_AttrInfo'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_FetchRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_KeyValueMessage'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_FetchResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_StoreRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_AX_StoreResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/AX.php';
$__autoload['Auth_OpenID_SRegBase'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/SReg.php';
$__autoload['Auth_OpenID_SRegRequest'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/SReg.php';
$__autoload['Auth_OpenID_SRegResponse'] = dirname(__FILE__).'/phpopenid/Auth/OpenID/SReg.php';
// end of include phpopenid
/**
 * @function fw_autoload
 * permits to include classes automatically
 * @param 	string		$pClassName		Name of the class
 */

function fw_autoload($pClassName) {
	
	
	if (isset($GLOBALS['classpath']) && is_array($GLOBALS['classpath'])) {
		foreach($GLOBALS['classpath'] as $path) {
			
			if (file_exists($path. $pClassName . '.class.php')) {
    			require_once $path . $pClassName . '.class.php';
    			break;
			}
		}
	}
}

spl_autoload_register("fw_autoload");

# session_auto_start emulation.
session_start();

if (defined('IN_PROXY'))
{
	session_write_close();
}

# language management at runtime.
if (Auth::isAuth()) $GLOBALS['lang'] = Auth::getLanguage(); 
?>